﻿@inject IEventService _eventService

@if (IsAnniversary)
{
    <a @onclick="OnClick" class="a-font-color">

        <MDCard Class="pa-3 mb-4 user-steam-card">
            <div class="user-info">
                <img src="@UserInfoModel.BasicInfor.PhotoPath" alt="@UserInfoModel.BasicInfor.Name" class="image" />
                <div class="name"> @UserInfoModel.BasicInfor.Name</div>
            </div>
            <div class="goal">
                <div class="value">@(GameRecords.Count)</div>
                <div class="key">总库存</div>
            </div>
            <div class="goal">
                <div class="value">@((GameRecords.Count*100.0/ TotalCount).ToString("0.0")+" %")</div>
                <div class="key">@($"收集率（站内总计 {TotalCount}）")</div>
            </div>
            <div class="goal">
                <div class="value">@((GameRecords.Sum(s=>s.PlayDuration)/60.0).ToString("0.0")+" h")</div>
                <div class="key">总时长</div>
            </div>
            <div class="goal">
                <div class="value">@(SteamUserInfors.Sum(s=>s.Price).ToString("0")+ " ¥")</div>
                <div class="key">总价格</div>
            </div>
        </MDCard>
    </a>
}
else
{
    @if (SteamUserInfors.Count == 1 && IsSmallScreen == false)
    {
        var item = SteamUserInfors[0];
        <MDCard Href="@("https://steamcommunity.com/profiles/"+item.SteamId)" Target="_blank" Class=" h-100 pa-2 mb-3" Style="    flex-direction: row; align-items: center;">
                <img style=" height: 50px;border-radius:50%; " src="@item.Image" alt="@item.Name" />
                <div class="ms-3" style=" display: flex; flex-direction: column; justify-content: space-between; ">
                    <div class="">
                        @item.Name
                    </div>
                    <div class="m-0" style="display: flex; flex-wrap: wrap; justify-content: space-between;">
                        <span class="me-4 d-flex">
                            <CnGalWebSite.Shared.MasaComponent.Shared.Components.MasaIcon Type="IconType.Duration" />
                            <span>@("总时长："+(GameRecords.Sum(s=>s.PlayDuration)/60.0).ToString("0.0")+" 小时")</span>
                        </span>
                        <span class="me-4 d-flex">
                            <CnGalWebSite.Shared.MasaComponent.Shared.Components.MasaIcon Type="IconType.Count" />
                            <span>@("总计："+GameRecords.Count)</span>

                        </span>
                        <span class="me-4 d-flex">
                            <CnGalWebSite.Shared.MasaComponent.Shared.Components.MasaIcon Type="IconType.WantToPlay" />
                            <span>@("想玩："+GameRecords.Count(s=>s.Type== PlayedGameType.WantToPlay))</span>
                        </span>
                        <span class="me-4 d-flex">
                            <CnGalWebSite.Shared.MasaComponent.Shared.Components.MasaIcon Type="IconType.Playing" />
                            <span>@("正在玩："+GameRecords.Count(s=>s.Type== PlayedGameType.Playing))</span>

                        </span>
                        <span class="me-4 d-flex">
                            <CnGalWebSite.Shared.MasaComponent.Shared.Components.MasaIcon Type="IconType.Played" />
                            <span>@("已玩："+GameRecords.Count(s=>s.Type== PlayedGameType.Played))</span>

                        </span>
                        <span class="me-4 d-flex">
                            <CnGalWebSite.Shared.MasaComponent.Shared.Components.MasaIcon Type="IconType.UnPlayed" />
                            <span>@("未玩："+GameRecords.Count(s=>s.Type== PlayedGameType.UnPlayed))</span>

                        </span>
                        <span class="d-flex">
                            <CnGalWebSite.Shared.MasaComponent.Shared.Components.MasaIcon Type="IconType.Uninterested" />
                            <span>@("不感兴趣："+GameRecords.Count(s=>s.Type== PlayedGameType.Uninterested))</span>

                        </span>
                    </div>
                </div>
        </MDCard>

    }
    else
    {
        <div class="row">
            @foreach (var item in SteamUserInfors)
            {
                <div class="col-12 col-md-6 col-xxl-4 h-100">
                    <MDCard Href="@("https://steamcommunity.com/profiles/"+item.SteamId)" Class="pa-2 mb-3" Style="    flex-direction: row;; align-items: center;" Target="_blank">
                            <img style=" height: 50px; border-radius: 50%; " src="@item.Image" alt="@item.Name" />
                            <div class="ms-3" style=" display: flex; align-items: center; ">
                                <span class="">
                                    @item.Name
                                </span>
                            </div>
                    </MDCard>
                </div>


            }
        </div>


        <MDCard Class=" h-100 pa-2 mb-3" Style="flex-direction: row;flex-wrap: wrap;justify-content: space-between;">
                <span class="me-4 d-flex">
                    <CnGalWebSite.Shared.MasaComponent.Shared.Components.MasaIcon Type="IconType.Duration" />
                    <span>@("总时长："+(GameRecords.Sum(s=>s.PlayDuration)/60.0).ToString("0.0")+" 小时")</span>
                </span>
                <span class="me-4 d-flex">
                    <CnGalWebSite.Shared.MasaComponent.Shared.Components.MasaIcon Type="IconType.Count" />
                    <span>@("总计："+GameRecords.Count)</span>

                </span>
                <span class="me-4 d-flex">
                    <CnGalWebSite.Shared.MasaComponent.Shared.Components.MasaIcon Type="IconType.WantToPlay" />
                    <span>@("想玩："+GameRecords.Count(s=>s.Type== PlayedGameType.WantToPlay))</span>

                </span>
                <span class="me-4 d-flex">
                    <CnGalWebSite.Shared.MasaComponent.Shared.Components.MasaIcon Type="IconType.Playing" />
                    <span>@("正在玩："+GameRecords.Count(s=>s.Type== PlayedGameType.Playing))</span>

                </span>
                <span class="me-4 d-flex">
                    <CnGalWebSite.Shared.MasaComponent.Shared.Components.MasaIcon Type="IconType.Played" />
                    <span>@("已玩："+GameRecords.Count(s=>s.Type== PlayedGameType.Played))</span>

                </span>
                <span class="me-4 d-flex">
                    <CnGalWebSite.Shared.MasaComponent.Shared.Components.MasaIcon Type="IconType.UnPlayed" />
                    <span>@("未玩："+GameRecords.Count(s=>s.Type== PlayedGameType.UnPlayed))</span>

                </span>
                <span class="d-flex">
                    <CnGalWebSite.Shared.MasaComponent.Shared.Components.MasaIcon Type="IconType.Uninterested" />
                    <span>@("不感兴趣："+GameRecords.Count(s=>s.Type== PlayedGameType.Uninterested))</span>

                </span>
        </MDCard>
    }
}


@code {
    [Parameter]
    public List<GameRecordViewModel> GameRecords { get; set; }
    [Parameter]
    public List<SteamUserInforModel> SteamUserInfors { get; set; }
    [Parameter]
    public bool IsSmallScreen { get; set; }
    [Parameter]
    public bool IsAnniversary { get; set; }
    [Parameter]
    public int TotalCount { get; set; }
    [Parameter]
    public PersonalSpaceViewModel UserInfoModel { get; set; }


    [CascadingParameter]
    public ErrorHandler ErrorHandler { get; set; }

    public async Task OnClick()
    {
        foreach (var item in SteamUserInfors)
        {
            await _eventService.OpenNewPage("https://steamcommunity.com/profiles/" + item.SteamId);
        }
    }

}
